package com.android.slidingmenuexample.menuactivities;

import java.util.Calendar;

import com.android.slidingmenuexample.R;
import com.android.slidingmenuexample.R.id;
import com.android.slidingmenuexample.R.layout;
import com.android.slidingmenuexample.R.menu;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TimePicker;

public class DateActivity extends Activity {
	
	int setHour;
	int setMinute;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
	    getActionBar().hide();
		
		
		setContentView(R.layout.activity_date);
		
		Button finishButton = (Button)findViewById(R.id.btn_finish);
		final DatePicker datePicker = (DatePicker)findViewById(R.id.date);
		final TimePicker timePicker = (TimePicker)findViewById(R.id.time);
		
		
		
		timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
			
			@Override
			public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				
				setHour = hourOfDay;
				setMinute = minute;
				
			}
		});

		
		finishButton.setOnClickListener(new Button.OnClickListener() {	
			
			@Override
			public void onClick(View v){
			
				getIntent().putExtra("data", Integer.toString(datePicker.getYear()) + "년 " 
						+ Integer.toString(datePicker.getMonth()+1) + "월 "
						+ Integer.toString(datePicker.getDayOfMonth()) + "일" + "\n"
						+ Integer.toString(setHour) + " : " 
						+ Integer.toString(setMinute)
						);
				setResult(RESULT_OK, getIntent());

				finish();
			}
		});
	}

	
}
